<?php
session_start();
class home extends Tpage{
	
	
    public function logar($sender,$param)
    { 	
        $name = $this->name->TEXT;
    	$password = $this->password->TEXT;

    	//realiza a pesquisa 
    	$user = usuarioRecord::finder()->findAll('StrUsuario = ? AND StrSenha = ?',$name, $password);
    	//$user = usuarioRecord::finder()->findAll();
    	
    	
    	
    	if($user != null)  // all validations succeed
        {   	
           $url = "?page=index";
           $_SESSION['usuario'] = $user["0"]->StrNome;
           $_SESSION['idUsuario'] = $user["0"]->PKCodLongUsuario;
           $_SESSION['permissao'] = $user["0"]->BooleanIsAdmin;
    	   $this->Response->  redirect($url); 
        }else{
        	//$this->Response->  redirect("?page=index"); 
        	$this->Mensagem->Text = "Usuário ou senha inválido";
        	//echo("Usuario ou senha inválido");
        }
    }	
}
?>